-
Notifications
You must be signed in to change notification settings - Fork 12
Governance (delegateVote) #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Coverage SummaryTotals
FilesExpand
|
|
Contract comparison - from 2f10986 to af0c61f
|
e60cb1e to
921678a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds governance voting functionality to the delegation contract, allowing delegators to vote on governance proposals using their active stake. The changes also update the multiversx-sc framework from version 0.58.0 to 0.60.0 and bump the contract version from 0.5.8 to 0.5.9.
Key changes:
- New governance module with
delegateVoteandgetVotingPowerendpoints - Framework upgrade from 0.58.0 to 0.60.0 across all crates
- Refactoring to pass references instead of owned values in fund view methods
- Migration from
statictoconstfor compile-time constants
Reviewed changes
Copilot reviewed 43 out of 55 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| latest/src/governance.rs | New module implementing vote delegation to governance SC |
| latest/src/delegation_main.rs | Integrates governance module into main contract |
| latest/src/settings.rs | Converts static constants to const for better semantics |
| user-fund-storage/src/fund_view_module.rs | Optimizes parameter passing by using references |
| user-fund-storage/Cargo.toml | Updates framework dependency to 0.60.0 |
| node-storage/Cargo.toml | Updates framework dependency to 0.60.0 |
| latest/Cargo.toml | Updates framework to 0.60.0 and version to 0.5.9 |
| latest/wasm-delegation_latest_update/src/lib.rs | Adds delegateVote and getVotingPower endpoint exports |
| latest/wasm-delegation_latest_full/src/lib.rs | Adds delegateVote and getVotingPower endpoint exports |
| latest/tests/latest_scenario_rs_test.rs | Fixes test attribute ordering and updates test names |
| latest/tests/latest_scenario_go_test.rs | Updates test names for version scenarios |
| latest/scenarios/version_full.scen.json | Updates expected version output to 0.5.9 |
| v0_5_9_update/output/delegation_v0_5_9_update.wasm | Generated WASM binary for update contract |
| v0_5_9_update/output/delegation_v0_5_9_update.abi.json | Generated ABI with new governance endpoints |
| v0_5_9_full/output/delegation_v0_5_9_full.wasm | Generated WASM binary for full contract |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[endpoint(delegateVote)] | ||
| fn delegate_vote(&self, proposal_to_vote: u64, vote: ManagedBuffer) { | ||
| let voter = self.blockchain().get_caller(); | ||
|
|
||
| let staked_balance = self.get_user_stake_of_type_by_address(&voter, FundType::Active); | ||
|
|
||
| self.tx() | ||
| .to(GovernanceSystemSCAddress) | ||
| .typed(GovernanceSCProxy) | ||
| .delegate_vote(proposal_to_vote, &vote, &voter, &staked_balance) | ||
| .callback( | ||
| self.callbacks() | ||
| .delegate_vote_callback(&voter, proposal_to_vote, &vote), | ||
| ) | ||
| .async_call_and_exit(); | ||
| } |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing input validation for the delegateVote endpoint. The function does not validate that the user has any active stake before making the external call. A user with zero active stake could still trigger an async call to the governance contract, wasting gas and potentially causing unexpected behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contract was tested with voting with 0.
No description provided.